home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form OLEShellForm
- Caption = "OLEShell"
- ClientHeight = 2220
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4035
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2220
- ScaleWidth = 4035
- StartUpPosition = 3 'Windows Default
- Begin VB.TextBox YText
- Height = 315
- Left = 540
- TabIndex = 4
- Text = "0"
- Top = 1740
- Width = 975
- End
- Begin VB.TextBox XText
- Height = 315
- Left = 540
- TabIndex = 3
- Text = "0"
- Top = 1200
- Width = 975
- End
- Begin VB.CommandButton OKButton
- Caption = "OK"
- Height = 375
- Left = 2820
- TabIndex = 2
- Top = 120
- Width = 1095
- End
- Begin VB.CommandButton ComputeOutputButton
- Caption = "Compute Output"
- Enabled = 0 'False
- Height = 375
- Left = 120
- TabIndex = 1
- Top = 600
- Width = 1455
- End
- Begin VB.CommandButton OpenBreadboardButton
- Caption = "Open Breadboard"
- Height = 375
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1455
- End
- Begin VB.Label ZOutputLabel
- Height = 315
- Left = 2160
- TabIndex = 8
- Top = 1500
- Width = 1095
- End
- Begin VB.Label ZLabel
- Caption = "Z:"
- Height = 255
- Left = 1800
- TabIndex = 7
- Top = 1500
- Width = 255
- End
- Begin VB.Label YLabel
- Caption = "Y:"
- Height = 255
- Left = 180
- TabIndex = 6
- Top = 1800
- Width = 255
- End
- Begin VB.Label XLabel
- Caption = "X:"
- Height = 255
- Left = 180
- TabIndex = 5
- Top = 1260
- Width = 255
- End
- Attribute VB_Name = "OLEShellForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim NSApp As Object
- Dim NSBB As Object
- Private Sub ComputeOutputButton_Click()
- 'Ensure that X and Y contain numerical values
- If (Not IsNumeric(XText.Text)) Or (Not IsNumeric(YText.Text)) Then
- MsgBox "X and Y must contain numerical values.", vbOKOnly + vbInformation
- Exit Sub
- End If
- 'Read X and Y input data from text boxes and prepare for sending to the
- 'OLE Input component on the example NeuroSolutions breadboard
- Dim xInput As Single
- xInput = CSng(XText.Text)
- Dim yInput As Single
- yInput = CSng(YText.Text)
- Dim inputData(0 To 1, 0 To 0) As Variant
- inputData(0, 0) = xInput
- inputData(1, 0) = yInput
- Dim inputDataWrapped As Variant
- inputDataWrapped = inputData
- 'Send input data to the OLE Input component
- NSBB.sendDataToEngine inputDataWrapped, "oLEInput"
- 'Resets epoch counter but doesn't reset weight because learning is turned off
- NSBB.send "control.resetNetwork()"
- 'Calculates network output for the given input
- NSBB.send "control.stepExemplar()"
- 'Get the network output and write it to Z
- Dim outputData As Variant
- outputData = NSBB.send("matrixViewer.getProbeData()")
- '"getProbeData" will fail if running in evaluation mode
- On Error Resume Next
- ZOutputLabel.Caption = Format(outputData(0, 0), "0.0000")
- On Error GoTo 0
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- ' NSApp.closeApplication
- Set NSBB = Nothing
- Set NSApp = Nothing
- End Sub
- Private Sub OKButton_Click()
- Unload Me
- End Sub
- Private Sub OpenBreadboardButton_Click()
- 'Open NeuroSolutions and maximize it
- Set NSApp = CreateObject("NeuroSolutions.Application")
- NSApp.maximize
- 'Determine the full path of the example NeuroSolutions breadboard
- Dim breadboardPathName As String
- breadboardPathName = NSApp.pathFromNS("OLE\Breadboard\MLPXor.nsb")
- If checkIfFileExists(breadboardPathName) = False Then
- breadboardPathName = App.Path & "\..\Breadboard\MLPXor.nsb"
- If checkIfFileExists(breadboardPathName) = False Then
- MsgBox "The breadboard for this example could not be found.", vbCritical + vbOKOnly
- Set NSApp = Nothing
- Exit Sub
- End If
- End If
- 'Open the example NeuroSolutions breadboard
- NSApp.openBreadboard breadboardPathName
- Set NSBB = NSApp.activeBreadboard
- NSBB.maximize
- 'Enable Compute Output button since breadboard was opened successfully
- ComputeOutputButton.Enabled = True
- End Sub
- Function checkIfFileExists(filePathName As String) As Boolean
- If (filePathName = "") Or (Dir(filePathName) = "") Then
- checkIfFileExists = False
- Else
- checkIfFileExists = True
- End If
- End Function
-